<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<title>留言</title>
	<link rel="stylesheet" type="text/css" href="<?php echo base_url()?>public/assets/css/amazeui.css">
	<link rel="stylesheet" type="text/css" href="<?php echo base_url()?>public/assets/css/bootstrap.min.css">
</head>
<body>
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      
      <a class="navbar-brand" href="#">写下你的留言吧！</a>
    </div>
  </div><!-- /.container-fluid -->
</nav>



<?php if(!empty($comment)):?>
<?php foreach ($comment as  $value) :?>
  <article class="am-comment" style="margin: 15px;">
  <a href="#link-to-user-home">
    <img src="<?php echo $value['headimgurl']?>" alt="" class="am-comment-avatar" width="48" height="48"/>
  </a>


  <div class="am-comment-main">
    <header class="am-comment-hd">
      <!--<h3 class="am-comment-title">评论标题</h3>-->
      <div class="am-comment-meta">
        <a href="#link-to-user" class="am-comment-author"><?php echo $value['nickname']?></a>
        留言于 <time ><?php echo $value['time']?></time>
      </div>
    </header>

    <div class="am-comment-bd">
      <?php echo $value['content']?>
    </div>
  </div>

</article>
<?php endforeach;?>
<?php else :?>
  <div class="alert alert-success" role="alert">...暂时还没有人留言</div>
<?php endif;?>

<center>
<nav>
	<!-- <ul class="pagination pagination-sm">
		<li>
	      <a href="#" aria-label="Previous">
	        <span aria-hidden="true">&laquo;</span>
	      </a>
	    </li>
	    <li><a href="#">1</a></li>
	    <li><a href="#">2</a></li>
	    <li><a href="#">3</a></li>
	    <li><a href="#">4</a></li>
	    <li><a href="#">5</a></li>
	    <li>
	      <a href="#" aria-label="Next">
	        <span aria-hidden="true">&raquo;</span>
	      </a>
	    </li>

	</ul> -->
  <?php echo $links;?>
</nav>
</center>

<div class="container-fuild">
  <div class="well">
    <form >
      <div class="form-group">
        <label for="intro">随便写点什么吧</label>
        <textarea rows="5" placeholder="随便写点什么啊" name="comment" id="comment" class="form-control"  style="border-radius:6px;" required ></textarea>
      </div>
      <button id="submit" class="btn btn-primary btn-lg btn-block" type="button">提交</button>
    </form>
  </div>
</div>

</body>
<script src="<?php echo base_url();?>public/assets/js/jquery-1.11.1.js"></script>
<script src="<?php echo base_url();?>public/assets/js/bootstrap.min.js"></script>


<script type="text/javascript">
  $("#submit").click(function(){
      if($('#comment').val()!=""){
        $.ajax({
        type :"POST",
        url  : "<?php echo site_url('comment/post_comment')?>",
        data : {'nickname':'<?php echo $nickname?>','headimgurl':'<?php echo $headimgurl?>','content':$('#comment').val()},
        success:function(data){
          if(data){
            alert('发表成功');
            location.href = location.href;
          }else{
            alert('发表失败');
            location.href = location.href;
          }
        }
      });
      }else{
        alert('提交数据不能为空');
        location.href = location.href;
        
      } 
     
  });

</script>
</html>